<?php
 use_helper("users");
if(2==$_REQUEST["userEdit"]){
    switch($_REQUEST["userload"])
            {
                case "1": //修改密码
                    echo "<script>showInfos(1,1);</script>";
                    break;
                case "2"://修改个人信息
                    echo "<script>showInfos(1,2);</script>";
                    break;
                case "3"://修改头像
                    echo "<script>showInfos(1,3);</script>";
                    break;
                case "4"://添加相册
                    echo "<script>showInfos(1,4);</script>";
                    break;
                case "5"://添加相片
                    echo "<script>showInfos(1,5,".$phogId.");</script>";
                    break;
                case "6"://删除相册
                    break;
                case "7"://删除相片
                case "8"://设为头像
                    echo "<script>window.location.href='".url_for("user/home?pho=".$phogId)."';</script>";
                case "9"://设为封面
                    echo "<script>showInfos(1,5,".$phogId.");</script>";
                    break;
                default://不做任何修改
                    break;
            }
}else{
switch($_REQUEST["userload"])
            {
                case "1": //加载密码
                    echo "<div class='userInfo_box_con'>
			  <h2><div class='com_tit'>更改密码<span>RESET PASSWORD</span></div></h2>
			  <form method='post' id='form' action='".url_for('user/turninfos')."' name='form' >
        <input type='hidden' name='userEdit' id='userEdit' value='2'/>
        <input type='hidden' name='userload' id='userload' value='1'/>
		     <ul class='userInfo_list'>
              <li>&nbsp;&nbsp;&nbsp;&nbsp;<font color='red'><b>".$result."</b></font></li>
              <li>&nbsp;&nbsp;&nbsp;&nbsp;旧密码：<input type='password' class='ipt211' id='password' name='password' ></li>
              <li>&nbsp;&nbsp;&nbsp;&nbsp;新密码：<input type='password' class='ipt211' id='repassword' name='repassword' ></li>
			  <li>确认新密码：<input type='password' class='ipt211' id='truesword' name='truesword' ></li>
             </ul><div style='text-align:center;padding-top:15px;padding-bottom:40px;'>
                  <input name='a1' class='sear01' onclick='return checkeds()' type='submit' value='提&nbsp;交' />　　<input name='a2' class='sear01' type='reset' value='重&nbsp;置' /></div>
        </form><script>function checkeds(){
          if(''==$('#password').attr('value'))
          {
             alert('原密码不能为空！');
            $('#password').focus();
             return false;
          }else if(''==$('#repassword').attr('value'))
          {
             alert('新密码不能为空！');
            $('#repassword').focus();
             return false;
          }else if($('#password').attr('value')==$('#repassword').attr('value'))
          {
             alert('原密码与新密码不能一致！');
              $('#repassword').select();
             return false;
          }else if(''==$('#truesword').attr('value'))
          {
             alert('确认不能为空！');
            $('#truesword').focus();
             return false;
          }else if($('#truesword').attr('value')!=$('#repassword').attr('value'))
          {
             alert('新密码与确认密码不一致！');
              $('#repassword').select();
             return false;
          }
}</script>
			</div>";
                    break;
                case "2"://加载个人信息
                    $userSex="male";
                    if('female'==trim($userinfo->getSex()))
                    {$userSex='female';}
                    echo "<div class='userInfo_box_con'>
			   <h2><div class='com_tit'>修改个人资料<span>PROFILFS</span></div></h2>
			   <form method='post' action='".url_for('user/turninfos')."' id='form' name='form'>
        <input type='hidden' name='userEdit' id='userEdit' value='2'/>
        <input type='hidden' name='userload' id='userload' value='2'/>
			   <table border='0' cellspacing='0' cellpadding='0' class='userInfo_table'>
  <tr>
    <td width='90' align='right'>用户名：</td>
    <td width='490'><b style='color:#333333'>".$userinfo->getName()."</b></td>
  </tr>
  <tr>
    <td align='right'>Email：</td>
    <td><input type='text' class='ipt211'  name='Info_email' value='".$userinfo->getEmail()."' ></td>
  </tr>
  <tr>
    <td align='right'>昵称：</td>
    <td><input type='text' class='ipt211'  name='Info_nice' value='".$userinfo->getNickname()."' ></td>
  </tr>
  <tr>
    <td align='right'>真是姓名：</td>
    <td><input type='text' class='ipt211'  name='Info_real' value='".$userinfo->getRealName()."' ></td>
  </tr>
  <tr>
    <td align='right'>性别：</td>
    <td><select id='Info_sex' name='Info_sex' >
         <option value='male'>男</option>
         <option value='female'>女</option>
       </select></td>
  </tr>
  <tr>
    <td align='right'>生日：</td>
    <td><input type='text' class='ipt211'  name='Info_birthday' value='".$userinfo->getBirthday()."' ></td>
  </tr>
  <tr>
    <td align='right'>联系电话：</td>
    <td><input type='text' class='ipt211'  name='Info_tel' value='".$userinfo->getTelephone()."' ></td>
  </tr>
  <tr>
    <td align='right'>手&nbsp;&nbsp;&nbsp;&nbsp;机：</td>
    <td><input type='text' class='ipt211'  name='Info_cel' value='".$userinfo->getCellphone()."' ></td>
  </tr>
  <tr>
    <td align='right'>详细地址：</td>
    <td><input type='text' class='ipt211'  name='Info_address' value='".$userinfo->getAddress()."' ></td>
  </tr>
</table><script>$('#Info_sex').attr('value','".$userSex."');</script>
			   <div style='text-align:center;padding-top:15px;padding-bottom:40px;'><input name='a1' class='sear01' type='submit' value='确定修改' />　　<input name='a2' class='sear01' type='reset' value='重&nbsp;置' /></div>
        </form>


			</div>";
                    break;
                case "3"://加载头像
                    echo "<div class='userInfo_box_con'>
			  <h2><div class='com_tit'>我的头像<span>HEAD PORTROIT</span></div></h2>
			   <div class='up_photo'>
			    上传头像：<form style='position:relative;left:80px;top:-18px;*top:-15px;' method='post' enctype='multipart/form-data' action='".url_for('user/turninfos')."'>
	<div id='view_photo'>
      <input type='file' name='file1' id='file1' onchange='preview5()'/>
        <input type='hidden' name='userEdit' id='userEdit' value='2'/>
        <input type='hidden' name='userload' id='userload' value='3'/>
      <p style='margin-bottom:10px;margin-top:8px;'>(大小为150*110像素最佳,3/4比例)</p>
   </div>
   <div style='padding-top:15px;'><input name='a1' class='sear01' type='submit' value='确定修改' />　　<input name='a2' class='sear01' type='reset' value='重&nbsp;置' /></div>
</form>
<script type='text/javascript'>
function preview5(){
var x = document.getElementById('file5');
if(!x || !x.value) return;
var patn = /\.jpg$|\.jpeg$|\.gif$/i;
if(patn.test(x.value)){}else{
alert('您选择的似乎不是图像文件。');
}}
</script></div></div>";
                    break;
                case "4"://相册管理
                    echo "<div class='userInfo_box_con'>
			  <h2><div class='com_tit' style='float:left;'>相册管理<span>MY PHOTOS</span></div><div class='potos_bq'><a href='javascript:addinfos(1,1)'>新建相册</a></div></h2>
			  <ul class='userInfo_photos_list'>";
            $photoGroups = @$pages->getResults();
            foreach($photoGroups as $row=>$photoGroup)
            {
                
                echo "<li><a class='userInfo_photos_box' href='javascript:showInfos(1,5,".$photoGroup->getPhotoGroupId().")'><img src='".fileExist($photoGroup->getSnapshot())."' border=0/></a>
					<p class='my_photo_a1'><a href='javascript:showInfos(1,5,".$photoGroup->getPhotoGroupId().")'>".$photoGroup->getTitle()."</a></p>
					<p class='my_photo_a2'><a href='javascript:showInfos(2,6,".$photoGroup->getPhotoGroupId().")'>删除相册</a></p>
				 </li>";
            }
                    echo "</ul>";
                    $numPages= $pages->getLastPage();
           $CurrentPageID=$pages->getPage();
             if(@$pages->haveToPaginate())
			{
				$str=$CurrentPageID-6;
				$end=$CurrentPageID+5;
				if($str<0)
					$str=0;
				if($end>$numPages)
					$end=$numPages;
				echo "<div class='page_list'>";
				if($CurrentPageID>1)
					echo link_to("上一页","currentPage=".($CurrentPageID-1),"");
				 for($i=$str;$i<$end;$i++)
				 {
					if($i==($CurrentPageID-1)){
					echo "<a class='now02' href='#'>".($i+1)."</a>";}
					else{
					    echo link_to(($i+1),"currentPage=".($i+1),"");
                    }
				 }
				 if($CurrentPageID<$numPages)
				 echo link_to("下一页","currentPage=".($CurrentPageID+1),"");
				 echo "</div>";
			}
			  echo "</div>";
                    //分页
                    break;
                case "5"://加载相片
                    echo "<div class='userInfo_box_con'>
			  <h2><div class='com_tit' style='float:left;'>我的相册夹->".$photoT->getTitle()."</div>
<div class='potos_bq'><a href='javascript:addinfos(1,4,".$photoT->getPhotoGroupId().")'>更改相册名</a> <a href='javascript:addinfos(1,2,".$photoT->getPhotoGroupId().")'>添加相片</a> <a href='javascript:showInfos(1,4)'>返回相册管理</a></div></h2>
			  <ul class='userInfo_photos_list userInfo_photos_list2'>";
                    $photos = @$pages->getResults();
            foreach($photos as $row=>$photo)
            {

                echo "<li>"."<a href='".$photo->getLink()."' target='_blank' class='userInfo_photos_box'><img src='".fileExist($photo->getLink())."' border=0/></a>
					<p class='my_photo_a1'><a href='".$photo->getLink()."' target='_blank'>".$photo->getBrief()."</a></p>
					<p class='my_photo_a2'><a href='javascript:showInfos(2,8,".$photo->getPhotoId().".".$photoT->getPhotoGroupId().")'>设为头像</a>
<a href='javascript:showInfos(2,9,".$photo->getPhotoId().".".$photoT->getPhotoGroupId().")'>设为相册封面</a></p>
					<p class='my_photo_a2'><a href='javascript:showInfos(2,7,".$photo->getPhotoId().".".$photoT->getPhotoGroupId().")'>删除照片</a></p>
				 </li>";
            };
                    echo "</ul>";
                    $numPages= $pages->getLastPage();
           $CurrentPageID=$pages->getPage();
             if(@$pages->haveToPaginate())
			{
				$str=$CurrentPageID-6;
				$end=$CurrentPageID+5;
				if($str<0)
					$str=0;
				if($end>$numPages)
					$end=$numPages;
				echo "<div class='page_list'>";
				if($CurrentPageID>1)
					echo link_to("上一页","currentPage=".($CurrentPageID-1),"");
				 for($i=$str;$i<$end;$i++)
				 {
					if($i==($CurrentPageID-1)){
					echo "<a class='now02' href='#'>".($i+1)."</a>";}
					else{
					    echo link_to(($i+1),"currentPage=".($i+1),"");
                    }
				 }
				 if($CurrentPageID<$numPages)
				 echo link_to("下一页","currentPage=".($CurrentPageID+1),"");
				 echo "</div>";
			}
			  echo "</div>";
                    //分页
                    break;
    case "5"://加载相片
                    echo "<div class='userInfo_box_con'>
			  <h2><div class='com_tit' style='float:left;'>我的相册夹->".$photoT->getTitle()."</div>
<div class='potos_bq'><a href='javascript:addinfos(1,4,".$photoT->getPhotoGroupId().")'>更改相册名</a> <a href='javascript:addinfos(1,2,".$photoT->getPhotoGroupId().")'>添加相片</a> <a href='javascript:showInfos(1,4)'>返回相册管理</a></div></h2>
			  <ul class='userInfo_photos_list userInfo_photos_list2'>";
                    $photos = @$pages->getResults();
            foreach($photos as $row=>$photo)
            {

                echo "<li>"."<a href='".$photo->getLink()."' target='_blank' class='userInfo_photos_box'><img src='".fileExist($photo->getLink())."' border=0/></a>
					<p class='my_photo_a1'><a href='".$photo->getLink()."' target='_blank'>".$photo->getBrief()."</a></p>
					<p class='my_photo_a2'><a href='javascript:showInfos(2,8,".$photo->getPhotoId().".".$photoT->getPhotoGroupId().")'>设为头像</a>
<a href='javascript:showInfos(2,9,".$photo->getPhotoId().".".$photoT->getPhotoGroupId().")'>设为相册封面</a></p>
					<p class='my_photo_a2'><a href='javascript:showInfos(2,7,".$photo->getPhotoId().".".$photoT->getPhotoGroupId().")'>删除照片</a></p>
				 </li>";
            };
                    echo "</ul>";
                    $numPages= $pages->getLastPage();
           $CurrentPageID=$pages->getPage();
             if(@$pages->haveToPaginate())
			{
				$str=$CurrentPageID-6;
				$end=$CurrentPageID+5;
				if($str<0)
					$str=0;
				if($end>$numPages)
					$end=$numPages;
				echo "<div class='page_list'>";
				if($CurrentPageID>1)
					echo link_to("上一页","currentPage=".($CurrentPageID-1),"");
				 for($i=$str;$i<$end;$i++)
				 {
					if($i==($CurrentPageID-1)){
					echo "<a class='now02' href='#'>".($i+1)."</a>";}
					else{
					    echo link_to(($i+1),"currentPage=".($i+1),"");
                    }
				 }
				 if($CurrentPageID<$numPages)
				 echo link_to("下一页","currentPage=".($CurrentPageID+1),"");
				 echo "</div>";
			}
			  echo "</div>";
                    //分页
                    break;
    case "6"://加载个人基本信息
                    $userSex="男";
                    if('female'==trim($userinfo->getSex()))
                    {$userSex='女';}
                    echo "<div class='userInfo_box_con'>
			   <h2><div class='com_tit'>个人资料<span>PROFILFS</span></div></h2>
			   <table border='0' cellspacing='0' cellpadding='0' class='userInfo_table'>
  <tr>
    <td width='90' align='right'><font size=3>用户名：</font></td>
    <td width='490'><font size=3 style='color:#01ACE0;'>".$userinfo->getName()."</font></td>
  </tr>
  <tr>
    <td align='right'><font size=3>Email：</font></td>
    <td><font size=3 style='color:#01ACE0;'>".$userinfo->getEmail()."</font></td>
  </tr>
  <tr>
    <td align='right'><font size=3>昵称：</font></td>
    <td><font size=3 style='color:#01ACE0;'>".$userinfo->getNickname()."</font></td>
  </tr>
  <tr>
    <td align='right'><font size=3>真是姓名：</font></td>
    <td><font size=3 style='color:#01ACE0;'>".$userinfo->getRealName()."</font></td>
  </tr>
  <tr>
    <td align='right'><font size=3>性别：</font></td>
    <td><font size=3 style='color:#01ACE0;'>".$userSex."</font></td>
  </tr>
  <tr>
    <td align='right'><font size=3>生日：</font></td>
    <td><font size=3 style='color:#01ACE0;'>".$userinfo->getBirthday()."</font></td>
  </tr>
  <tr>
    <td align='right'><font size=3>联系电话：</font></td>
    <td><font size=3 style='color:#01ACE0;'>".$userinfo->getTelephone()."</font></td>
  </tr>
  <tr>
    <td align='right'><font size=3>手&nbsp;&nbsp;&nbsp;&nbsp;机：</font></td>
    <td><font size=3 style='color:#01ACE0;'>".$userinfo->getCellphone()."</font></td>
  </tr>
  <tr>
    <td align='right'><font size=3>详细地址：</font></td>
    <td><font size=3 style='color:#01ACE0;'>".$userinfo->getAddress()."</font></td>
  </tr>
</table></div>";
                    break;
                default://默认信息
                    break;
            }
}
?>